package com.proxy;

import java.lang.reflect.Method;

//静态代理类
public class ProxyUserServicesImpl implements UserServices{
    private  UserServicesImpl userServices;

    public void setUserServices(UserServicesImpl userServices) {
        this.userServices = userServices;
    }

    @Override
    public void add() {
        try {
          Method method= ProxyUserServicesImpl.class.getMethod("add");
          getLog(method.getName());
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }

        userServices.add();
    }

    @Override
    public void del() {
        try {
            Method method= ProxyUserServicesImpl.class.getMethod("del()",ProxyUserServicesImpl.class);
            getLog(method.getName());
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
        userServices.del();
    }

    @Override
    public void sel() {
        userServices.sel();
    }

    @Override
    public void upd() {
    userServices.upd();
    }

    public void getLog(String msg){
        System.out.println("日志:执行了"+msg+"方法");
    }
}
